﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;
using CnGine.Web;

public partial class login : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user"] != null)
        {
            Response.Redirect("/member/");
        }
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string account = txtAccount.Text.Trim().ToLower();
        string password = txtPassword.Text.Trim();
        string code = txtCode.Text.Trim().ToLower();
        if (Session["RandomCode"] != null && code.Equals(Session["RandomCode"].ToString().ToLower()))
        {
            BLL.User bll = new BLL.User();
            string sql = string.Format(" UserName='{0}'", account);
            Model.User user = bll.GetModel(sql);
            if (user != null)
            {
                if (password.Equals(user.UserPassword))
                {
                    Session["user"] = user;
                    Response.Redirect("/member/");
                }
                else
                {
                    MessageBox.Show(this.Page, "账户或者密码错误！");
                }
            }
            else
            {
                MessageBox.Show(this.Page, "账户或者密码错误！");
            }
        }
        else
        {
            MessageBox.Show(this.Page, "验证码错误！");
        }
    }
}